<?php /*a:3:{s:49:"D:\phpstudy_pro\WWW\night\app\view\cls\index.html";i:1600343404;s:53:"D:\phpstudy_pro\WWW\night\app\view\public\header.html";i:1602463826;s:53:"D:\phpstudy_pro\WWW\night\app\view\public\footer.html";i:1601179064;}*/ ?>

    <title>Title</title>
    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <script src="/static/layui/layui.js"></script>
    <script src="/static/jquery.min.js"></script>
</head>
<body class="layui-layout-body">

<div class="layui-layout layui-layout-admin">

    <div class="layui-header">
        <div class="layui-logo">商品后台管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="/index/welcome">首页</a></li>
<!--            <li class="layui-nav-item"><a href="/node/add">节点添加</a></li>-->
            <li class="layui-nav-item">
                <a href="javascript:;">其它系统</a>
                <dl class="layui-nav-child">
                    <dd><a href="">邮件管理</a></dd>
                    <dd><a href="">消息管理</a></dd>
                    <dd><a href="">授权管理</a></dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    <?php echo htmlentities($user['admin_name']); ?>
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="/admin/LoginOut">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <?php foreach($node_list as $key=>$vo): ?>
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;"><?php echo htmlentities($vo['node_name']); ?></a>
                    <dl class="layui-nav-child">

                        <?php foreach($vo['node'] as $k=>$v): ?>
                        <dd><a href="<?php echo htmlentities($v['node_url']); ?>"><?php echo htmlentities($v['node_name']); ?></a></dd>
                        <?php endforeach; ?>
                    </dl>
                </li>
                <?php endforeach; ?>
<!--                <li class="layui-nav-item">-->
<!--                    <a href="javascript:;">解决方案</a>-->
<!--                    <dl class="layui-nav-child">-->
<!--                        <dd><a href="javascript:;">列表一</a></dd>-->
<!--                        <dd><a href="javascript:;">列表二</a></dd>-->
<!--                        <dd><a href="">超链接</a></dd>-->
<!--                    </dl>-->
<!--                </li>-->
<!--                <li class="layui-nav-item"><a href="">云市场</a></li>-->
<!--                <li class="layui-nav-item"><a href="">发布商品</a></li>-->
            </ul>
        </div>
    </div>

    <div class="layui-body">

    <div id="test12" class="demo-tree-more"></div>
    <script>
        layui.use(['tree', 'util'], function(){
            var tree = layui.tree
                ,layer = layui.layer
                ,util = layui.util
                ,$ = layui.jquery;

                var data1 = [];
                $.ajax({
                    type:"POST",
                    url:"data",
                    dataType:"JSON",
                    async:false,
                    success:function (msg) {
                        data1 = msg;
                    }
                });


            //基本演示
            tree.render({
                elem: '#test12'
                ,data: data1
                ,showCheckbox: true  //是否显示复选框
                ,edit: ['add', 'update', 'del'] //操作节点的图标
                ,id: 'demoId1'
                ,isJump: true //是否允许点击节点时弹出新窗口跳转
                ,click: function(obj){
                    var data = obj.data;  //获取当前点击的节点数据
                    layer.msg('状态：'+ obj.state + '<br>节点数据：' + JSON.stringify(data));
                }
                ,operate: function(obj){
                    var type = obj.type; //得到操作类型：add、edit、del
                    var data = obj.data; //得到当前节点的数据
                    var elem = obj.elem; //得到当前节点元素

                    //Ajax 操作
                    var id = data.id; //得到节点索引
                    if(type === 'add'){ //增加节点
                        location.href="add/id/"+id;
                    } else if(type === 'update'){ //修改节点
                        //location.href="add/id/"+id;
                        var cate_name =  elem.find('.layui-tree-txt').html(); //得到修改后的内容
                        $.post('update',
                            {
                                id:id,
                                cate_name:cate_name
                            },
                            function (data) {
                                if(data.code == 400){
                                    alert(data.msg);
                                    location.reload();
                                }
                            }
                        )

                    } else if(type === 'del'){ //删除节点
                        $.post('del',
                            {
                                id:id
                            },
                            function (data) {
                            alert(data.msg);

                            }
                        )
                    }
                     }
            });



            //按钮事件
            util.event('lay-demo', {
                getChecked: function(othis){
                    var checkedData = tree.getChecked('demoId1'); //获取选中节点的数据

                    layer.alert(JSON.stringify(checkedData), {shade:0});
                    console.log(checkedData);
                }
                ,setChecked: function(){
                    tree.setChecked('demoId1', [12, 16]); //勾选指定节点
                }
                ,reload: function(){
                    //重载实例
                    tree.reload('demoId1', {

                    });

                }
            });


            //开启节点操作图标
            tree.render({
                elem: '#test9'
                ,data: data1
                ,edit: ['add', 'update', 'del'] //操作节点的图标
                ,click: function(obj){
                    layer.msg(JSON.stringify(obj.data));
                }
            });
        });
    </script>
    
</div>
</div>

<!--<div class="layui-footer">-->
<!--    &lt;!&ndash; 底部固定区域 &ndash;&gt;-->
<!--    © layui.com - 底部固定区域-->
<!--</div>-->
</div>
<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
</script>
</body>
</html>
